|
$webwork.htmlEncode($page.space.name) : KML Placemark Templates
This page last changed on Jan 16, 2008 by jdeolive.
Create Custom Placemark Descriptions with Templates
Introduction IntroductionIn KML a "Placemark" is used to mark a position on a map, often visualized with a yellow push pin. A placemark can have a "description" which allows one to attach information to it. Placemark descriptions are nothing more then an HTML snippet and can contain anything we want it to. By default GeoServer produces placemark descriptions which are HTML tables describing all the attributes available for a particular feature in a dataset. In the following image we see the placemark description for the feature representing Idaho state:
This is great, but what about if one wanted some other sort of information to be conveyed in the description. Or perhaps one does not want to show all the attributes of the dataset. The answer is Templates!! A template is more or less a way to create some output Getting StartedFirst let us get set up. To complete the tutorial you will need the following:
And thats it. For this tutorial we will assume that GeoServer is running the same configuration ( data directory ) that it does out of the box. Hello WorldOk, time to get to creating our first template. We will start off an extremely simple template which, you guessed it, creates the placemark description "Hello World!". So lets go.
And thats it. We can now test out our template by adding the following network link in google earth: http://localhost:8080/geoserver/wms/kml_reflect?layers=states
And voila. Your first template.
As stated before template descriptions are nothing more than html. Play around with description.ftl and add some of your own html. Some examples you may want to try:
The possibilities are endless. Now this is all great and everything but these examples are some what lacking in that the content is static. In the next section we will create more realistic template which actually access some the attributes of our dataset. Dynamic ContentThe real power of templates is the ability to easily access content, in the case of features this content is the attributes of features.In a KML placemark description template, there are a number of "template variables" available.
So with this knowledge in hand let us come up with some more examples:
WMS Demo ExampleWe will base our final example off the "WMS Example" demo which ships with GeoServer. To check out the demo visit http://localhost:8080/geoserver/popup_map/index.html in your web browser. You will notice that hovering the mouse over one of the points on the map displays an image specific to that point. Let us replicate this with a KML placemark description.
|
| Document generated by Confluence on Jan 16, 2008 23:27 |